package controller;
import model.*;
public class ProductController
{ private ProductContainer productCont;
    
    public ProductController()
    {
        productCont=ProductContainer.getInstance();
    }
    public Product findProduct(String barcode) {
         
        Product product = productCont.findProduct(barcode);
        if(product != null) {
            return product;
        }
        else {
            System.out.println("No such product in the system");
            return null;
        }
    }
    public boolean addProduct(String barcode, String location,String name,double price)
    {
        Product productObj = new Product(barcode, location, name, price);
        if(productObj != null)
        {
            productCont.addProduct(productObj);
            return true;
        }
        else 
        {
            return false;
        }
    }

    public boolean removeProduct(String barcode) {
        if(findProduct(barcode)!= null) 
        {
            productCont.removeProduct(barcode);
            return  true;
        }
        else 
        {
            return false;
        }
    }
   /* public boolean updateProduct(String oldBarcode, Product newProduct)
    {
        boolean success = false;
        success = productCont.updateProduct(oldBarcode, newProduct);
        return success;
    }*/
    
}
